// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程：https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
const WechatServer = require('./server/index.js')
const WechatApi = require('./server/api.js')
const userModel = require('./server/user.js')
module.exports = {
	_before() {

	},
	async getQrCodeImg() {
		let res = await WechatApi.getTicketImg()
		return res
	},
	setMenu() {
		return WechatApi.setMenu()
	},
	getUserInfo(params) {
		return userModel.getUserInfo(params.code)
	},
	wxlogin(params) {
		return userModel.login(params.code)
	},
	notice() {
		let $app = new WechatServer(this.getHttpInfo())
		let vail = $app.token();
		if (vail) {
			// 处理其他业务
			return $app.token()
		} else {
			return '';
		}
	},
 	async testWhereQuery(openid){
		const db = uniCloud.database()
		let { data } = await db.collection("wechat-user").where({openid}).get()
		return data
	}
}
